home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Systemmonitors / SWAP / SWAP.c < prev    next >
C/C++ Source or Header  |  1996-09-26  |  60KB  |  1,958 lines

  1. /* SWAP.c .  Copyright © Kamran karimi. This program tries to bring swapping to
  2.    Amiga without the need of hardware. Compiled with Lattice C 3.1 . 
  3.    Should be linked with PatchSignaling.o to produce executable.
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <exec/types.h>
  9. #include <exec/execbase.h>
  10. #include <exec/memory.h>
  11. #include <exec/ports.h>
  12. #include <libraries/dos.h>
  13. #include <libraries/dosextens.h>
  14. #include <intuition/intuitionbase.h>
  15. #include <intuition/intuition.h>
  16.  
  17. #define RastPort (MainWin->RPort)
  18.  
  19. #define SUCCESS 0
  20. #define FAILER  1
  21.  
  22. #define TASKS   0
  23. #define WINSCR  1
  24. #define MEMORY  2
  25. #define INFO    3
  26.  
  27. #define NOMEM      0
  28. #define FAILED     1 
  29. #define DONE       2
  30. #define NOTME      3
  31. #define NOTFOUND   4
  32. #define NOTASK     5
  33. #define NOSUICIDE  6
  34. #define CONFIRM    7
  35. #define CANCELED   8
  36. #define NEWPRI     9
  37. #define OUTRANGE  10
  38. #define SIGMASK   11
  39. #define NOGRAPH   12
  40. #define NOFILE    13
  41. #define NOSEG     14
  42. #define NOSPC     15
  43. #define WERROR    16
  44. #define RERROR    17
  45. #define OCCUPIED1 18
  46. #define OCCUPIED2 19
  47. #define SWAPPED   20
  48. #define NSWAPPED  21
  49. #define NOTIMP    22
  50. #define WAIT      23
  51. #define NSWAPME   24
  52. #define FREED     25
  53. #define NOKILL    26
  54. #define NOBREAK   27
  55. #define NOSIGNAL  28
  56. #define NOFREEZE  29
  57. #define INTRUDER  30
  58. #define INTNFOUND 31
  59.  
  60. static UWORD ColourTable[] = {0x99a,0xfff,0x000,0x082};
  61.  
  62. struct NewScreen MyScreen = {0,0,640,200,2,0,1,HIRES,CUSTOMSCREEN,NULL,
  63.     " SWAP         By Kamran Karimi",NULL,NULL};
  64.  
  65.  
  66. UBYTE UNDOBuff[100];
  67.  
  68. UBYTE  SBuff[100];
  69.  
  70. UBYTE  Temp[100];
  71.  
  72. UBYTE CRam[12],FRam[12],SwapS[12],SelTask[80];
  73.  
  74. struct TextAttr MyFont = {
  75.  (STRPTR)"topaz.font",TOPAZ_EIGHTY,FS_NORMAL,FPF_ROMFONT};
  76.  
  77. struct StringInfo GadgetSInfo = {SBuff,UNDOBuff,0,100,0,0,0,0,0,0,0,0,NULL};
  78.  
  79. struct PropInfo PGInfo = {AUTOKNOB|FREEVERT,-1,-1,0,0,0,0,0,0,0,0};
  80.  
  81. struct Image Image1 = {0,0,12,67,0,NULL,0x0000,0x0000,NULL};
  82.  
  83. USHORT  Up[] = {
  84. 0x0200,                     /* 0000001000000 */
  85. 0x0700,                     /* 0000011100000 */
  86. 0x0f80,                     /* 0000111110000 */
  87. 0x1fc0,                     /* 0001111111000 */
  88. 0x3fe0,                     /* 0011111111100 */
  89. 0x7ff0                      /* 0111111111110 */
  90. }; 
  91.  
  92. USHORT  Down[] = {
  93. 0x7ff0,                     /* 0111111111110 */
  94. 0x3fe0,                     /* 0011111111100 */
  95. 0x1fc0,                     /* 0001111111000 */
  96. 0x0f80,                     /* 0000111110000 */
  97. 0x0700,                     /* 0000011100000 */
  98. 0x0200                      /* 0000001000000 */
  99. };
  100.  
  101. USHORT *UpData,*DownData;
  102.  
  103. struct Image UpArrow = {0,1,13,6,1,Up,1,0,NULL};
  104.  
  105. struct Image DownArrow = {0,84,13,6,1,Down,1,0,(struct Image *)&UpArrow};
  106.  
  107. SHORT BorderPairs[][6] = {
  108.  {0,8,0,0,18,0},
  109.  {18,0,18,8,0,8},
  110.  {0,8,0,0,18,0},
  111.  {18,0,18,8,0,8},
  112.  {0,0,0,0,0,0},
  113.  {0,0,0,0,0,0},
  114.  {0,11,0,0,65,0}, /* keys */
  115.  {65,0,65,11,0,11},
  116.  {0,12,0,0,66,0},
  117.  {66,0,66,12,0,12},
  118.  {0,11,0,0,148,0},    /* big key */
  119.  {148,0,148,11,0,11},
  120.  {0,12,0,0,149,0},
  121.  {149,0,149,12,0,12},
  122.  {0,15,0,0,70,0},       /* exit */
  123.  {70,0,70,15,0,15},
  124.  {0,16,0,0,71,0},
  125.  {71,0,71,16,0,16},
  126.  {0,10,0,0,341,0},      /* string */
  127.  {341,0,341,10,0,10},
  128.  {0,11,0,0,343,0},      
  129.  {343,0,343,11,0,11},
  130.  {0,95,0,26,595,26},   /* big area  */
  131.  {595,26,595,95,0,95},
  132.  {0,96,0,26,597,26},   
  133.  {597,26,597,96,0,96},
  134.  {0,108,0,98,595,98},
  135.  {595,98,595,108,0,108}, 
  136.  {0,198,0,155,254,155},  /* message area */
  137.  {254,155,254,198,0,198},
  138.  {0,199,0,155,256,155},  
  139.  {256,155,256,199,0,199},
  140.  {0,152,0,142,254,142},
  141.  {254,142,254,152,0,152},
  142.  {1,22,1,0,160,0},     /* RAM */
  143.  {160,0,160,22,1,22},
  144.  {0,11,0,0,200,0},
  145.  {200,0,200,11,0,11},
  146.  {0,11,0,0,595,0},
  147.  {595,0,595,11,0,11},
  148.  {625,24,625,94,608,94},
  149.  {624,24,624,94,607,94}
  150.  
  151. }; /* end of BorderPairs structure */
  152.  
  153. struct Border RevBorder[] = {
  154.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[0],NULL},
  155.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[1],(struct Border *) &RevBorder[0]},
  156.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[2],NULL},
  157.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[3],(struct Border *) &RevBorder[2]},
  158.  {0,0,0,0,0,0,0,0},
  159.  {0,0,0,0,0,0,0,0},
  160.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[6],NULL},
  161.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[7],(struct Border *) &RevBorder[6]},
  162.  {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[8],(struct Border *) &RevBorder[7]},
  163.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[9],(struct Border *) &RevBorder[8]},
  164.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[10],NULL},
  165.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[11],(struct Border *) &RevBorder[10]},
  166.  {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[12],(struct Border *) &RevBorder[11]},
  167.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[13],(struct Border *) &RevBorder[12]},
  168.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[14],NULL},
  169.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[15],(struct Border *) &RevBorder[14]},
  170.  {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[16],(struct Border *) &RevBorder[15]},
  171.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[17],(struct Border *) &RevBorder[16]}
  172.  
  173. }; /* end of struct RevBorder */
  174.  
  175. struct Border Borders[] = {
  176.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[0],NULL},
  177.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[1],(struct Border *) &Borders[0]},
  178.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[2],NULL},
  179.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[3],(struct Border *) &Borders[2]},
  180.  {0,0,0,0,0,0,0,0},
  181.  {0,0,0,0,0,0,0,0},
  182.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[6],NULL},
  183.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[7],(struct Border *) &Borders[6]}, 
  184.  {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[8],(struct Border *) &Borders[7]},
  185.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[9],(struct Border *) &Borders[8]},
  186.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[10],NULL},
  187.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[11],(struct Border *) &Borders[10]},
  188.  {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[12],(struct Border *) &Borders[11]},
  189.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[13],(struct Border *) &Borders[12]}, 
  190.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[14],NULL},
  191.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[15],(struct Border *) &Borders[14]},
  192.  {-3,-2,2,0,JAM1,3,(SHORT *) BorderPairs[16],(struct Border *) &Borders[15]},
  193.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[17],(struct Border *) &Borders[16]},
  194.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[18],NULL},
  195.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[19],(struct Border *) &Borders[18]},
  196.  {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[20],(struct Border *) &Borders[19]},
  197.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[21],(struct Border *) &Borders[20]},
  198.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[22],NULL},
  199.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[23],(struct Border *) &Borders[22]},
  200.  {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[24],(struct Border *) &Borders[23]},
  201.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[25],(struct Border *) &Borders[24]},
  202.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[26],(struct Border *) &Borders[25]},
  203.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[27],(struct Border *) &Borders[26]},
  204.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[28],(struct Border *) &Borders[27]},
  205.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[29],(struct Border *) &Borders[28]},
  206.  {-3,-2,1,0,JAM1,3,(SHORT *) BorderPairs[30],(struct Border *) &Borders[29]},
  207.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[31],(struct Border *) &Borders[30]},
  208.  {-2,-1,1,0,JAM1,3,(SHORT *) BorderPairs[32],(struct Border *) &Borders[31]},
  209.  {-2,-1,2,0,JAM1,3,(SHORT *) BorderPairs[33],(struct Border *) &Borders[32]},
  210.  {262,163,2,0,JAM1,3,(SHORT *) BorderPairs[34],(struct Border *) &Borders[33]},
  211.  {262,163,1,0,JAM1,3,(SHORT *) BorderPairs[35],(struct Border *) &Borders[34]},
  212.  {262,188,2,0,JAM1,3,(SHORT *) BorderPairs[36],(struct Border *) &Borders[35]},
  213.  {262,188,1,0,JAM1,3,(SHORT *) BorderPairs[37],(struct Border *) &Borders[36]},
  214.  {-2,11,1,0,JAM1,3,(SHORT *) BorderPairs[38],(struct Border *) &Borders[37]},
  215.  {-2,11,2,0,JAM1,3,(SHORT *) BorderPairs[39],(struct Border *) &Borders[38]},
  216.  {-6,0,2,0,JAM1,3,(SHORT *) BorderPairs[40],(struct Border *) &Borders[39]},
  217.  {-6,0,2,0,JAM1,3,(SHORT *) BorderPairs[41],(struct Border *) &Borders[40]}
  218.  
  219. }; /* end of Borders structure */
  220.  
  221.  
  222. struct IntuiText Texts[] = {
  223.  {0,0,0,0,0,0,0,0},                      /* 0  */
  224.  {0,0,0,0,0,0,0,0},                      /* 1  */
  225.  {0,0,0,0,0,0,0,0},                      /* 2  */
  226.  {2,0,JAM2,8,1,&MyFont,"Update",NULL},   /* 3  */
  227.  {2,0,JAM2,16,1,&MyFont,"Info",NULL},    /* 4  */
  228.  {2,0,JAM2,8,1,&MyFont,"Freeze",NULL},   /* 5  */
  229.  {2,0,JAM2,14,1,&MyFont," Pri ",NULL},   /* 6  */
  230.  {2,0,JAM2,17,1,&MyFont,"Kill",NULL},    /* 7  */
  231.  {2,0,JAM2,2,1,&MyFont,"Swap In",NULL},  /* 8  */
  232.  {2,0,JAM2,-1,1,&MyFont,"Swap Out",NULL},/* 9  */
  233.  {2,0,JAM2,8,1,&MyFont,"Signal",NULL},   /* 10 */
  234.  {2,0,JAM2,12,1,&MyFont,"Break",NULL},   /* 11 */
  235.  {2,0,JAM2,12,1,&MyFont,"Segs ",NULL},   /* 12 */
  236.  {2,0,JAM2,8,1,&MyFont,"Memory",NULL},   /* 13 */
  237.  {2,0,JAM2,11,1,&MyFont," W&S ",NULL},   /* 14 */
  238.  {2,0,JAM2,21,1,&MyFont,"Find Intruder",NULL},  /* 15 */
  239.  {2,0,JAM2,17,3,&MyFont,"Exit",NULL},    /* 16 */
  240.  {2,0,JAM2,400,99,&MyFont,"At Address:",NULL},
  241.  {2,0,JAM2,5,99,&MyFont,"Selected Task:     ",(struct IntuiText *) &Texts[17]},
  242.  {2,0,JAM2,100,142,&MyFont,"Message",(struct IntuiText *) &Texts[18]},          
  243.  {2,0,JAM2,270,190,&MyFont,"Swap Space:",(struct IntuiText *) &Texts[19]},        
  244.  {2,0,JAM2,272,176,&MyFont,"FastMem:",(struct IntuiText *) &Texts[20]},
  245.  {2,0,JAM2,272,165,&MyFont,"ChipMem:",(struct IntuiText *) &Texts[21]},
  246.  {2,0,JAM2,268,140,&MyFont,"Swap Out File:      ",
  247.                                              (struct IntuiText *) &Texts[22]},
  248.  {2,0,JAM2,5,14,&MyFont,
  249.   "      Name             Pri   State    Stack   Type     Signals   Address",
  250.   (struct IntuiText *) &Texts[23]}, 
  251.  {1,0,JAM2,335,176,&MyFont,FRam,NULL},
  252.  {1,0,JAM2,335,165,&MyFont,CRam,(struct IntuiText *) &Texts[25]},
  253.  {1,0,JAM2,360,190,&MyFont,SwapS,NULL},
  254.  {1,0,JAM2,118,99,&MyFont,SelTask,NULL},
  255.  {2,0,JAM2,268,140,&MyFont,"Enter New Priority:",NULL},
  256.  {2,0,JAM2,268,140,&MyFont,"Enter Signal Mask: ",NULL},
  257.  {2,0,JAM2,5,1,&MyFont," Tasks ",NULL}, 
  258.  {2,0,JAM2,5,14,&MyFont,
  259.   "                                                      (TASK INFORMATION)",
  260.   NULL},
  261.  {2,0,JAM2,5,14,&MyFont,
  262.   " Start Address      End Address        Size   Type (SEGMENT INFORMATION)",
  263.   NULL},  
  264.  {2,0,JAM2,5,14,&MyFont,
  265.   "                                                                        ",
  266.   NULL}, 
  267.  {2,0,JAM2,5,14,&MyFont,
  268.   "            Name                                       IDCMP     Address",
  269.   NULL},
  270.  {2,0,JAM2,400,99,&MyFont,"At Address:",(struct IntuiText *) &Texts[35]},
  271.  {2,0,JAM2,5,99,&MyFont,"Selected Element: ",(struct IntuiText *) &Texts[36]},
  272.  {2,0,JAM2,12,1,&MyFont,"Close",NULL},  
  273.  {2,0,JAM2,12,1,&MyFont,"Merge",NULL}, 
  274.  {2,0,JAM2,5,14,&MyFont,
  275.   "   Chunk Addr        Size     Type              #   (MEMORY INFORMATION)",
  276.   NULL},  
  277.  {2,0,JAM2,5,99,&MyFont,"Selected Chunk Address:     ",
  278.   (struct IntuiText *) &Texts[40]},
  279.  {2,0,JAM2,8,1,&MyFont," Melt ",NULL},  
  280.  
  281. }; /* end of Texts structure */ 
  282.  
  283.  
  284.  
  285. struct IntuiText SelTexts[] = {
  286.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 0 */
  287.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 1 */
  288.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 2 */
  289.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 3 */
  290.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 4 */
  291.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}, /* 5 */
  292.  {1,0,JAM2,2,1,&MyFont,NULL,NULL}  /* 6 */
  293.  
  294. };
  295.  
  296. char  ETextAddr[4][32];
  297.  
  298. struct IntuiText ErrIntuiText[] = {
  299.  {1,0,JAM2,7,157,&MyFont,ETextAddr[0],NULL},  /* 0 */
  300.  {1,0,JAM2,7,167,&MyFont,ETextAddr[1],NULL},  /* 1 */
  301.  {1,0,JAM2,7,177,&MyFont,ETextAddr[2],NULL},  /* 2 */
  302.  {1,0,JAM2,7,187,&MyFont,ETextAddr[3],NULL}   /* 3 */
  303. }; 
  304.  
  305. struct Gadget Bools[] = {
  306.  {(struct Gadget *) &Bools[1],617,15,15,7,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
  307.   BOOLGADGET,(APTR)&Borders[1],(APTR)&RevBorder[1],NULL,NULL,NULL,0,NULL},
  308.  
  309.  {(struct Gadget *) &Bools[2],617,97,15,7,GADGHIMAGE,GADGIMMEDIATE|RELVERIFY,
  310.   BOOLGADGET,(APTR)&Borders[3],(APTR)&RevBorder[3],NULL,NULL,NULL,1,NULL},
  311.  
  312.  {(struct Gadget *) &Bools[3],615,24,20,71,NULL,RELVERIFY,PROPGADGET,
  313.   (APTR)&Image1,NULL,NULL,NULL,    (APTR)&PGInfo,2,NULL},
  314.  
  315.  {(struct Gadget *) &Bools[4],43,112,62,10,GADGHIMAGE,RELVERIFY,BOOLGADGET,
  316.   (APTR)&Borders[9],(APTR)&RevBorder[9],(struct IntuiText *) &Texts[3],
  317.   NULL,NULL,3,NULL},
  318.  
  319.  {(struct Gadget *) &Bools[5],127,112,62,10,GADGHIMAGE|GADGDISABLED,
  320.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  321.    (struct IntuiText *) &Texts[4],NULL,NULL,4,NULL},
  322.  
  323.  {(struct Gadget *) &Bools[6],214,112,62,10,GADGHIMAGE|GADGDISABLED,
  324.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  325.    (struct IntuiText *) &Texts[5],NULL,NULL,5,NULL},
  326.  
  327.  {(struct Gadget *) &Bools[7],300,112,62,10,GADGHIMAGE|GADGDISABLED,
  328.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  329.    (struct IntuiText *) &Texts[6],NULL,NULL,6,NULL},
  330.  
  331.  {(struct Gadget *) &Bools[8],384,112,62,10,GADGHIMAGE|GADGDISABLED,
  332.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  333.    (struct IntuiText *) &Texts[7],NULL,NULL,7,NULL},
  334.  
  335.  {(struct Gadget *) &Bools[9],466,112,62,10,GADGHIMAGE|GADGDISABLED,
  336.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  337.    (struct IntuiText *) &Texts[8],NULL,NULL,8,NULL},
  338.  
  339.  {(struct Gadget *) &Bools[10],549,112,62,10,GADGHIMAGE|GADGDISABLED,
  340.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  341.    (struct IntuiText *) &Texts[9],NULL,NULL,9,NULL},
  342.  
  343.  {(struct Gadget *) &Bools[11],43,127,62,10,GADGHIMAGE|GADGDISABLED,
  344.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  345.    (struct IntuiText *) &Texts[10],NULL,NULL,10,NULL},
  346.  
  347.  {(struct Gadget *) &Bools[12],127,127,62,10,GADGHIMAGE|GADGDISABLED,
  348.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  349.    (struct IntuiText *) &Texts[11],NULL,NULL,11,NULL},
  350.  
  351.  {(struct Gadget *) &Bools[13],214,127,62,10,GADGHIMAGE|GADGDISABLED,
  352.    RELVERIFY,BOOLGADGET,(APTR)&Borders[9],(APTR)&RevBorder[9],
  353.    (struct IntuiText *) &Texts[12],NULL,NULL,12,NULL},
  354.  
  355.  {(struct Gadget *) &Bools[14],300,127,62,10,GADGHIMAGE,RELVERIFY,BOOLGADGET,
  356.   (APTR)&Borders[9],(APTR)&RevBorder[9],(struct IntuiText *) &Texts[13],
  357.   NULL,NULL,13,NULL},
  358.  
  359.  {(struct Gadget *) &Bools[15],384,127,62,10,GADGHIMAGE,RELVERIFY,BOOLGADGET,
  360.   (APTR)&Borders[9],(APTR)&RevBorder[9],(struct IntuiText *) &Texts[14],
  361.   NULL,NULL,14,NULL},
  362.  
  363.  {(struct Gadget *) &Bools[16],466,127,145,10,GADGHIMAGE|GADGDISABLED,
  364.    RELVERIFY,BOOLGADGET,(APTR)&Borders[13],(APTR)&RevBorder[13],
  365.    (struct IntuiText *) &Texts[15], NULL,NULL,15,NULL},
  366.  
  367.  {(struct Gadget *) &Bools[17],550,183,30,15,GADGHIMAGE,RELVERIFY,BOOLGADGET,
  368.   (APTR)&Borders[17],(APTR)&RevBorder[17],(struct IntuiText *) &Texts[16],
  369.   NULL,NULL,16,NULL},   
  370.  
  371.  {NULL,280,150,338,9,NULL,RELVERIFY,STRGADGET,
  372.  (APTR)&Borders[21],NULL,NULL,NULL,(APTR)&GadgetSInfo,17,NULL},
  373.  
  374. }; /* end of Bools structure */
  375.  
  376. struct Gadget Select[] = {
  377.  {(struct Gadget *) &Select[1],14,26,594,9,GADGHCOMP,RELVERIFY,
  378.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[0],NULL,NULL,20,NULL},
  379.  
  380.  {(struct Gadget *) &Select[2],14,35,594,10,GADGHCOMP,RELVERIFY,
  381.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[1],NULL,NULL,21,NULL},
  382.  
  383.  {(struct Gadget *) &Select[3],14,45,594,10,GADGHCOMP,RELVERIFY,
  384.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[2],NULL,NULL,22,NULL},
  385.  
  386.  {(struct Gadget *) &Select[4],14,55,594,10,GADGHCOMP,RELVERIFY,
  387.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[3],NULL,NULL,23,NULL},
  388.  
  389.  {(struct Gadget *) &Select[5],14,65,594,10,GADGHCOMP,RELVERIFY,
  390.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[4],NULL,NULL,24,NULL},
  391.  
  392.  {(struct Gadget *) &Select[6],14,75,594,10,GADGHCOMP,RELVERIFY,
  393.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[5],NULL,NULL,25,NULL},
  394.  
  395.  {NULL,14,85,594,9,GADGHCOMP,RELVERIFY,
  396.   BOOLGADGET,NULL,NULL,(struct IntuiText *) &SelTexts[6],NULL,NULL,26,NULL},
  397.  
  398. };
  399.  
  400. struct NewWindow MyWindow = {0,0,640,200,0,1,GADGETDOWN|GADGETUP,
  401.        SIMPLE_REFRESH|BACKDROP+BORDERLESS,(struct Gadget *) &Bools[0],NULL,
  402.        NULL,NULL,NULL,5,5,640,200,CUSTOMSCREEN };
  403.  
  404.  
  405. char *ErrorT[] = {
  406.  "Could not allocate memory!     ",
  407.  "Operation failed!              ",
  408.  "Operation Done                 ",
  409.  "I can not freeze myself!       ",
  410.  "Task not found!                ",
  411.  "No task selected               ",
  412.  "I won't commit Suicide!        ",
  413.  "Click again to confirm ...     ",
  414.  "Operation canceled             ",
  415.  "Give new task priority         ",
  416.  "Given priority was not valid!  ",
  417.  "Give signal mask in hexadecimal",
  418.  "No window or screen selected!  ",
  419.  "Could not open swap file!      ",
  420.  "No Segment found!              ",
  421.  "Not enough space in swap file! ",
  422.  "Could not write to swap file!  ",
  423.  "Could not read swap file!      ",
  424.  "Task memory occupied!          ",
  425.  "Could not swap in the task!    ",
  426.  "Task already swapped out       ", 
  427.  "Task has not been swapped out! ",
  428.  "This Option is not Implemented!",
  429.  "Please Wait ...                ",
  430.  "I can not swap out myself!     ",
  431.  "Allocated memory freed         ",
  432.  "Can't kill a swapped task      ",
  433.  "Can't break a swapped task     ",
  434.  "Can't Signal a swapped task    ",
  435.  "Can't freeze a swapped task    ", 
  436.  "Intruder task address:00000000 ",
  437.  "Intruder not found!            ",
  438.  
  439. };
  440.  
  441. struct TInfo  {
  442.  struct TInfo *next,*prev;
  443.  struct Task *Addr;
  444.  char *name;
  445.  char tempname[40];
  446.  char data[80];
  447. };
  448.  
  449.  
  450. extern struct ExecBase *SysBase;
  451. struct IntuitionBase *IntuitionBase;
  452. struct GfxBase *GfxBase; 
  453. struct DOSBase *DOSBase;
  454. struct Window *MainWin;
  455. struct Screen *MainScr;
  456. struct IntuiMessage *message;
  457. struct Gadget *GadgetPtr;
  458. struct TInfo *first = NULL,*ItemAddr[7],*tinfo,*current,*GraphPtr = NULL; 
  459. struct Task *task,*PrevSelected = NULL;
  460. struct MsgPort *MP,*PredMP;
  461.  
  462. USHORT SelectPos,TaskNum,GadgetNum,Row = 0,OldVPot,SMask;
  463.  
  464. APTR FirstSeg,SegAddr,CurSeg;
  465.  
  466. FILE *file;
  467.  
  468. ULONG State,SSpace,ChipRam,FastRam,class,SigMask,SegSum,SegSize,NumSwap;
  469.  
  470. UBYTE *state[10] = {"NonVal","Added","Runing","Ready","Waiting","Except",
  471.                    "Remove","Error","Frozen","Swapped"};
  472.  
  473. UBYTE *type[17] = {"Unknown","Task","Interrupt","Device","MsgPort","Message",
  474.  "FreeMsg","ReplyMsg","Resource","Library","Memory","SoftInt","Font",
  475.  "Process","Semaphore","SignalSem","BootNode"};
  476.  
  477. UBYTE *BCPLtoC();
  478.  
  479. void Open_UserInterface(),DisplayRam(),CloseAll(),Freeze(),ModifyP(),Pri();
  480. void UpdateTasks(),FreeList(),GetTaskName(),DisplaySwap(),PropMoved();
  481. void WipeGadg(),SwapIn(),FindIntruder(),FreeSwap();
  482. void MoveUp(),MoveDown(),NewSelect(),Update(),Message(),Kill(),Break();
  483. void SendSig(),GetInfo(),Seg(),ClearSelect(),WinScr(),Mem(),SwapOut();
  484.  
  485. int GetList(),GetTaskInfo(),Confirm(),PatchSignaling();
  486.  
  487. APTR FindFirstSegment();
  488.  
  489. int CXBRK() { return(0); }
  490.  
  491. void _main()
  492. {
  493.  strcpy(SBuff,"DF0:");
  494.  Open_UserInterface();
  495.  do {
  496.   WaitPort(MainWin->UserPort);
  497.   message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
  498.   GadgetPtr = (struct Gadget *)message->IAddress;
  499.   GadgetNum = GadgetPtr->GadgetID;
  500.   ReplyMsg((struct Message *) message);
  501.   switch (GadgetNum)
  502.   {
  503.    case  0: MoveDown(1);
  504.             break; 
  505.    case  1: MoveUp(1);
  506.             break; 
  507.    case  2: PropMoved();
  508.             break; 
  509.    case  3: Update();
  510.             break;
  511.    case  4: GetInfo();
  512.             break;
  513.    case  5: Freeze();
  514.             break;
  515.    case  6: Pri();
  516.             break;
  517.    case  7: Kill();
  518.             break;
  519.    case  8: SwapIn();
  520.             UpdateTasks();
  521.             DisplayRam();
  522.             break;
  523.    case  9: SwapOut();
  524.             DisplaySwap();
  525.             break;
  526.    case 10: SendSig();
  527.             break;
  528.    case 11: Break();
  529.             break;
  530.    case 12: Seg();
  531.             break;
  532.    case 13: Mem();
  533.             break;
  534.    case 14: WinScr();
  535.             break;
  536.    case 15: FindIntruder();
  537.             break;
  538.    case 16: if(Confirm(16)) GadgetNum = 100;
  539.             break;
  540.    case 17: DisplaySwap();
  541.             break;
  542.    case 20:
  543.    case 21:
  544.    case 22:
  545.    case 23:
  546.    case 24:
  547.    case 25:
  548.    case 26: NewSelect();
  549.             break;
  550.  
  551.    default: break;
  552.   }
  553.  }while(GadgetNum != 16);          
  554.  if(first) FreeList();
  555.  CloseAll(0L);
  556. }
  557.  
  558.  
  559. void Open_UserInterface()
  560. {
  561.  if(!(IntuitionBase = (struct IntuitionBase *) 
  562.                           OpenLibrary("intuition.library",0L))) CloseAll(20L);
  563.  
  564.  if (!(GfxBase = (struct GfxBase *)
  565.                           OpenLibrary("graphics.library",0L))) CloseAll(20L);
  566.  
  567.  if (!(DOSBase = (struct DOSBase *)
  568.                           OpenLibrary("dos.library",0L))) CloseAll(20L);
  569.  
  570.  UpData = (USHORT *) AllocMem(sizeof(Up),MEMF_CHIP);
  571.  DownData = (USHORT *) AllocMem(sizeof(Down),MEMF_CHIP);
  572.  CopyMem(Up,UpData,sizeof(Up));
  573.  CopyMem(Down,DownData,sizeof(Down));
  574.  UpArrow.ImageData = UpData;
  575.  DownArrow.ImageData = DownData;
  576.  if(!(MainScr = (struct Screen *) OpenScreen(&MyScreen))) CloseAll(10L);
  577.  LoadRGB4(&(MainScr->ViewPort),ColourTable,4);
  578.  MyWindow.Screen = MainScr;
  579.  if(!(MainWin = (struct Window *) OpenWindow(&MyWindow))) CloseAll(10L); 
  580.  DrawBorder(RastPort,(struct Border *) &Borders[41],15L,0L);
  581.  PrintIText(RastPort,(struct IntuiText *) &Texts[24],10,0);
  582.  DrawImage(RastPort,&DownArrow,618L,14L);
  583.  SelectPos = AddGList(MainWin,Select,-1,7,NULL);
  584.  Update();
  585.  if(PatchSignaling()) CloseAll(10L);
  586.  State = TASKS;
  587. }
  588.  
  589.  
  590. void Update()
  591. {
  592.  int count; 
  593.  
  594.  UpdateTasks();
  595.  DisplayRam();
  596.  DisplaySwap();
  597.  PrevSelected = NULL;
  598.  GraphPtr = NULL;
  599.  strcpy(SelTask,"NONE                               ");
  600.  PrintIText(RastPort,(struct IntuiText *)&Texts[28],10,0);
  601.  strcpy(SelTask,"N/A     ");
  602.  PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0); 
  603.  if((Bools[4].Flags & GADGDISABLED) == NULL)
  604.  {
  605.   RemoveGList(MainWin,&Bools[3],13);
  606.   for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  607.   Bools[3].Flags &= ~GADGDISABLED;
  608.   Bools[13].Flags &= ~GADGDISABLED;
  609.   Bools[14].Flags &= ~GADGDISABLED;
  610.   AddGList(MainWin,&Bools[3],3,13,NULL);
  611.   RefreshGList(&Bools[3],MainWin,NULL,13);
  612.  }
  613. }
  614.  
  615.  
  616. void NewSelect()
  617. {
  618.  short x1 = 10,x2 = 384;
  619.  UBYTE PrevS,CurS;
  620.  int count;
  621.  struct Task *PS;
  622.  
  623.  if(State != INFO)
  624.  {
  625.   PS = PrevSelected;
  626.   if(State == WINSCR)  x1 = 36;
  627.   if(State == MEMORY)  x2 = 84;
  628.   if(TaskNum < (GadgetNum - 19))
  629.   {
  630.    PrevSelected = NULL;
  631.    GraphPtr = NULL;
  632.    if(PS == NULL) return;
  633.    RemoveGList(MainWin,&Bools[3],13);
  634.    for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  635.    if(State != MEMORY)
  636.    {
  637.     strcpy(SelTask,"NONE                               ");
  638.     PrintIText(RastPort,(struct IntuiText *)&Texts[28],x1,0);
  639.     if(State == WINSCR)  Bools[14].Flags &= ~GADGDISABLED;
  640.     if(State == TASKS)
  641.     {
  642.      Bools[3].Flags &= ~GADGDISABLED;
  643.      Bools[13].Flags &= ~GADGDISABLED;
  644.      Bools[14].Flags &= ~GADGDISABLED;
  645.     }
  646.    } 
  647.    else  Bools[13].Flags &= ~GADGDISABLED;
  648.    AddGList(MainWin,&Bools[3],3,13,NULL);
  649.    RefreshGList(&Bools[3],MainWin,NULL,13);
  650.    strcpy(SelTask,"N/A     ");
  651.    PrintIText(RastPort,(struct IntuiText *)&Texts[28],x2,0);
  652.   }
  653.   else 
  654.   { 
  655.    PrevSelected = ItemAddr[GadgetNum - 20]->Addr;
  656.    GraphPtr = ItemAddr[GadgetNum - 20];
  657.    if(State != MEMORY)
  658.    {
  659.     sprintf(SelTask,"%-35.35s",ItemAddr[GadgetNum -20]->name);
  660.     PrintIText(RastPort,(struct IntuiText *)&Texts[28],x1,0);
  661.    }
  662.    if(PS == NULL)
  663.    {
  664.     RemoveGList(MainWin,&Bools[3],13);
  665.     if(State == TASKS)
  666.     { 
  667.      for (count = 3;count != 16;count++)  Bools[count].Flags &= ~GADGDISABLED;
  668.      Bools[8].Flags = Bools[9].Flags = Bools[15].Flags |= GADGDISABLED;
  669.     }
  670.     if(State == WINSCR) Bools[7].Flags &= ~GADGDISABLED;
  671.     if(State == MEMORY) Bools[6].Flags &= ~GADGDISABLED;
  672.     AddGList(MainWin,&Bools[3],3,13,NULL);
  673.     WipeGadg();
  674.     RefreshGList(&Bools[3],MainWin,NULL,13);
  675.    }
  676.    if(State == TASKS)
  677.    {
  678.     if(PrevSelected->tc_State == 8) Bools[5].GadgetText = &Texts[42];
  679.     else Bools[5].GadgetText = &Texts[5];
  680.     RefreshGList(&Bools[5],MainWin,NULL,1);
  681.     if(PrevSelected->tc_State == 9 || PrevSelected->tc_State == 2)
  682.     {
  683.      RemoveGList(MainWin,&Bools[3],13);
  684.      for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  685.      if(PrevSelected->tc_State == 9) 
  686.       Bools[4].Flags = Bools[8].Flags = Bools[15].Flags &= ~GADGDISABLED;
  687.      else 
  688.      {
  689.       Bools[4].Flags &= ~GADGDISABLED; 
  690.       Bools[10].Flags = Bools[11].Flags = Bools[12].Flags &= ~GADGDISABLED;
  691.      }
  692.      Bools[3].Flags = Bools[13].Flags = Bools[14].Flags &= ~GADGDISABLED;
  693.      Bools[6].Flags &=~GADGDISABLED; 
  694.      AddGList(MainWin,&Bools[3],3,13,NULL);
  695.      PrevS = PS->tc_State; CurS = PrevSelected->tc_State;
  696.      if(!((PrevS == 2 && CurS == 2) || (PrevS == 9 && CurS == 9))) WipeGadg();
  697.      if(PrevS == 2 && CurS == 9) WipeGadg(); 
  698.      RefreshGList(&Bools[3],MainWin,NULL,13);
  699.     }
  700.     else if(PS->tc_State == 9 || PS->tc_State == 2)
  701.     {
  702.      RemoveGList(MainWin,&Bools[3],13);
  703.      for (count = 3;count != 16;count++)  Bools[count].Flags &= ~GADGDISABLED;
  704.      Bools[9].Flags = Bools[8].Flags = Bools[15].Flags |= GADGDISABLED;
  705.      AddGList(MainWin,&Bools[3],3,13,NULL);
  706.      WipeGadg();
  707.      RefreshGList(&Bools[3],MainWin,NULL,13);
  708.     }
  709.    }
  710.    sprintf(SelTask,"%08lx",PrevSelected);
  711.    PrintIText(RastPort,(struct IntuiText *)&Texts[28],x2,0); 
  712.   }
  713.  }
  714.   
  715.  
  716. void ModifyP(Pos)
  717. int Pos;
  718. {
  719.  long vbody;
  720.  USHORT vb;
  721.  
  722.  if (TaskNum < 8) vbody = MAXBODY;
  723.  else vbody = (MAXBODY * 7) / TaskNum;
  724.  vb = (USHORT)vbody;
  725.  NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
  726.                Pos,PGInfo.HorizBody,vb,1);
  727.  OldVPot = Pos;
  728.  
  729.  
  730. void MoveUp(param)
  731. int param; 
  732. {
  733.  int count;
  734.  
  735.  do
  736.  { 
  737.   if (TaskNum < 8) return;
  738.   if (ItemAddr[6]->next == NULL) 
  739.   {
  740.    if(param) ModifyP(-1);
  741.    return;
  742.   }
  743.   RemoveGList(MainWin,Select,7);
  744.   for(count = 0;count < 7;count++)
  745.   {
  746.    ItemAddr[count] = ItemAddr[count]->next;
  747.    SelTexts[count].IText = ItemAddr[count]->data;
  748.   }
  749.   AddGList(MainWin,Select,-1,7,NULL);
  750.   RefreshGList(Select,MainWin,NULL,7);
  751.   if(param)
  752.   {
  753.    OldVPot = OldVPot + MAXBODY / (TaskNum - 7);
  754.    NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
  755.                 OldVPot,PGInfo.HorizBody,PGInfo.VertBody,1);
  756.   }
  757.   if(!param) break;
  758.   message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
  759.  } while(message == NULL);
  760.  if(param) ReplyMsg((struct Message *) message);
  761. }
  762.  
  763.  
  764. void MoveDown(param)
  765. int param;
  766. {
  767.  int count;
  768.  
  769.  do
  770.  { 
  771.   if (TaskNum < 8) return;
  772.   if (ItemAddr[0]->prev == NULL) 
  773.   {
  774.    if(param) ModifyP(0);
  775.    return;
  776.   }
  777.   RemoveGList(MainWin,Select,7);
  778.   for(count = 0;count < 7;count++)
  779.   {
  780.    ItemAddr[count] = ItemAddr[count]->prev;
  781.    SelTexts[count].IText = ItemAddr[count]->data;
  782.   }
  783.   AddGList(MainWin,Select,-1,7,NULL);
  784.   RefreshGList(Select,MainWin,NULL,7);
  785.   if(param)
  786.   {
  787.    OldVPot = OldVPot - MAXBODY / (TaskNum - 7);
  788.    NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
  789.                 OldVPot,PGInfo.HorizBody,PGInfo.VertBody,1);
  790.   }
  791.   if(!param) break;
  792.   message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
  793.  } while(message == NULL); 
  794.  if(param) ReplyMsg((struct Message *) message);
  795. }
  796.  
  797.  
  798. void PropMoved()
  799. {
  800.  short factor = 1;
  801.   
  802.  if (TaskNum < 8) return;
  803.  if(max(OldVPot,PGInfo.VertPot) == OldVPot) factor = -1;
  804.  if(factor == 1) 
  805.  {
  806.   while(OldVPot < PGInfo.VertPot)
  807.   { 
  808.    MoveUp(0);
  809.    if(OldVPot > (0xffff - (MAXBODY / (TaskNum - 7))))
  810.    {
  811.     OldVPot = 0xffff;
  812.     break;
  813.    }
  814.    OldVPot = OldVPot + MAXBODY / (TaskNum - 7);
  815.   }
  816.  }
  817.  else 
  818.  {
  819.   while(OldVPot > PGInfo.VertPot)
  820.   {
  821.    MoveDown(0);
  822.    if(OldVPot < (MAXBODY / (TaskNum - 7)))
  823.    {
  824.     OldVPot = 0;
  825.     break;
  826.    } 
  827.    OldVPot = OldVPot - MAXBODY / (TaskNum - 7);
  828.   }
  829.  }
  830.  NewModifyProp(&Bools[2],MainWin,NULL,PGInfo.Flags,PGInfo.HorizPot,
  831.                OldVPot,PGInfo.HorizBody,PGInfo.VertBody,1);
  832. }
  833.  
  834.  
  835. int Confirm(GadgNum)
  836. int GadgNum;
  837. {
  838.  Message(CONFIRM);
  839.  WaitPort(MainWin->UserPort);
  840.  message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
  841.  class = message->Class;
  842.  GadgetPtr = (struct Gadget *)message->IAddress;
  843.  GadgetNum = GadgetPtr->GadgetID;
  844.  ReplyMsg((struct Message *) message); 
  845.  switch(GadgetNum)
  846.  {
  847.   case  0: MoveDown(1);
  848.            break;
  849.   case  1: MoveUp(1);
  850.            break;   
  851.   case  2: PropMoved();
  852.            break;
  853.  } 
  854.  if(GadgetNum == GadgNum) return(SUCCESS);
  855.  Message(CANCELED);
  856.  return(FAILER);
  857. }
  858.  
  859.  
  860. void Mem()
  861. {
  862.  struct MemHeader *memheader;
  863.  struct MemChunk *memchunk;
  864.  struct TInfo *cur,*ti;
  865.  int count,type;
  866.  
  867.  PrevSelected = NULL;
  868.  if(State == MEMORY)
  869.  {
  870.   State = TASKS;
  871.   RemoveGList(MainWin,&Bools[3],13);
  872.   Bools[13].GadgetText = &Texts[13];
  873.   Bools[6].GadgetText = &Texts[6];
  874.   for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  875.   Bools[3].Flags &= ~GADGDISABLED;
  876.   Bools[13].Flags &= ~GADGDISABLED;
  877.   Bools[14].Flags &= ~GADGDISABLED;
  878.   AddGList(MainWin,&Bools[3],3,13,NULL);
  879.   WipeGadg();
  880.   RefreshGList(&Bools[3],MainWin,NULL,13);
  881.   Texts[24].NextText = NULL;
  882.   PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
  883.   Texts[24].NextText = &Texts[23];
  884.   PrintIText(RastPort,(struct IntuiText *)&Texts[18],10,0);
  885.   strcpy(SelTask,"NONE                               ");
  886.   PrintIText(RastPort,(struct IntuiText *)&Texts[28],10,0);
  887.   strcpy(SelTask,"N/A     ");
  888.   PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0); 
  889.   UpdateTasks();
  890.   return;
  891.  }
  892.  State = MEMORY;
  893.  PrintIText(RastPort,(struct IntuiText *)&Texts[37],10,0);
  894.  RemoveGList(MainWin,&Bools[3],13);
  895.  Bools[13].GadgetText = &Texts[31];
  896.  Bools[6].GadgetText = &Texts[39];
  897.  for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  898.  Bools[13].Flags &= ~GADGDISABLED;
  899.  AddGList(MainWin,&Bools[3],3,13,NULL);
  900.  RefreshGList(&Bools[3],MainWin,NULL,13);
  901.  PrintIText(RastPort,(struct IntuiText *)&Texts[41],10,0); 
  902.  strcpy(SelTask,"N/A                                               ");
  903.  PrintIText(RastPort,(struct IntuiText *)&Texts[28],84,0);
  904.  current = NULL;
  905.  TaskNum = 0;
  906.  if(first) FreeList();
  907.  if(GetList()) return;
  908.  first = tinfo;
  909.  Disable();
  910.  for(memheader = (struct MemHeader *)SysBase->MemList.lh_Head;
  911.      memheader->mh_Node.ln_Succ;
  912.      memheader = (struct MemHeader *)memheader->mh_Node.ln_Succ)
  913.  {
  914.   if(memheader->mh_Attributes & MEMF_CHIP) type = 1;
  915.   else type = 0;
  916.   for(memchunk = memheader->mh_First;memchunk;memchunk = memchunk->mc_Next)
  917.   {
  918.    TaskNum++;
  919.    if(type) strcpy(tinfo->tempname,"CHIP");
  920.    else strcpy(tinfo->tempname,"FAST");
  921.    tinfo->Addr = (struct Task *)memchunk;
  922.    sprintf(tinfo->data,"    %08lx   %10lu     %s     %10u  %-23.23s",
  923.            memchunk,memchunk->mc_Bytes - sizeof(struct MemChunk),
  924.            tinfo->tempname,TaskNum," ");
  925.    if(GetList()) {Enable(); return;}
  926.   }
  927.  }
  928.  Enable();
  929.  ti = tinfo->prev;
  930.  ti->next = NULL;
  931.  FreeMem(tinfo,sizeof(struct TInfo));
  932.  for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++) 
  933.  {
  934.   ItemAddr[count] = cur;
  935.   SelTexts[count].IText = cur->data;
  936.  }
  937.  if(count < 7) ClearSelect(count);
  938.  RefreshGList(Select,MainWin,NULL,7); 
  939.  ModifyP(0);
  940. }
  941.  
  942.  
  943. void WinScr()
  944. {
  945.  struct Screen *CurScr;
  946.  struct Window *CurWin;
  947.  struct TInfo *cur,*ti;
  948.  int count;
  949.  
  950.  PrevSelected = NULL;
  951.  if(State == WINSCR)
  952.  {
  953.   State = TASKS;
  954.   RemoveGList(MainWin,&Bools[3],13);
  955.   Bools[14].GadgetText = &Texts[14];
  956.   Bools[7].GadgetText = &Texts[7];
  957.   for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  958.   Bools[3].Flags &= ~GADGDISABLED;
  959.   Bools[13].Flags &= ~GADGDISABLED;
  960.   Bools[14].Flags &= ~GADGDISABLED;
  961.   AddGList(MainWin,&Bools[3],3,13,NULL);
  962.   WipeGadg();
  963.   RefreshGList(&Bools[3],MainWin,NULL,13);
  964.   Texts[24].NextText = NULL;
  965.   PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
  966.   Texts[24].NextText = &Texts[23];
  967.   PrintIText(RastPort,(struct IntuiText *)&Texts[18],10,0);
  968.   strcpy(SelTask,"NONE                               ");
  969.   PrintIText(RastPort,(struct IntuiText *)&Texts[28],10,0);
  970.   strcpy(SelTask,"N/A     ");
  971.   PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0); 
  972.   UpdateTasks();
  973.   GraphPtr = NULL;
  974.   return;
  975.  }
  976.  State = WINSCR;
  977.  PrintIText(RastPort,(struct IntuiText *)&Texts[37],10,0);
  978.  RemoveGList(MainWin,&Bools[3],13);
  979.  Bools[14].GadgetText = &Texts[31];
  980.  Bools[7].GadgetText = &Texts[38];
  981.  for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  982.  Bools[14].Flags &= ~GADGDISABLED;
  983.  AddGList(MainWin,&Bools[3],3,13,NULL);
  984.  RefreshGList(&Bools[3],MainWin,NULL,13);
  985.  strcpy(SelTask,"NONE                               ");
  986.  PrintIText(RastPort,(struct IntuiText *)&Texts[28],36,0);
  987.  strcpy(SelTask,"N/A     ");
  988.  PrintIText(RastPort,(struct IntuiText *)&Texts[28],384,0); 
  989.  current = NULL;
  990.  TaskNum = 0;
  991.  if(first) FreeList();
  992.  Disable();
  993.  CurScr = IntuitionBase->FirstScreen;
  994.  if(GetList()) {Enable(); return;}
  995.  first = tinfo;
  996.  while(CurScr)
  997.  {
  998.   sprintf(tinfo->data,"Screen:%-54.54s    %08lx",
  999.           CurScr->Title,CurScr);
  1000.   tinfo->Addr = (struct Task *)CurScr;
  1001.   strcpy(tinfo->tempname,"screen");
  1002.   tinfo->name = CurScr->Title;
  1003.   TaskNum++;
  1004.   CurWin = CurScr->FirstWindow;
  1005.   while(CurWin)
  1006.   {
  1007.    if(GetList()) {Enable(); return;}
  1008.    sprintf(tinfo->data,"Window:%-45.45s  %08lx   %08lx",
  1009.            CurWin->Title,CurWin->IDCMPFlags,CurWin);
  1010.    tinfo->Addr = (struct Task *)CurWin;
  1011.    strcpy(tinfo->tempname,"window");
  1012.    tinfo->name = CurWin->Title;
  1013.    CurWin = CurWin->NextWindow;
  1014.    TaskNum++;
  1015.   }
  1016.   CurScr = CurScr->NextScreen;
  1017.   if(GetList()) {Enable(); return;}
  1018.  }
  1019.  Enable();
  1020.  ti = tinfo->prev;
  1021.  ti->next = NULL;
  1022.  FreeMem(tinfo,sizeof(struct TInfo));
  1023.  for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++) 
  1024.  {
  1025.   ItemAddr[count] = cur;
  1026.   SelTexts[count].IText = cur->data;
  1027.  }
  1028.  if(count < 7) ClearSelect(count);
  1029.  RefreshGList(Select,MainWin,NULL,7); 
  1030.  ModifyP(0);
  1031. }  
  1032.   
  1033.  
  1034. void SwapOut()
  1035. {
  1036.  ULONG Lower,Sig[3];
  1037.  APTR segment;
  1038.  int actual;
  1039.  
  1040.  if(!PrevSelected) { Message(NOTASK); return;}
  1041.  if(!FindTask(PrevSelected->tc_Node.ln_Name)) {Message(NOTFOUND); return;}
  1042.  if(PrevSelected->tc_State == 2) { Message(NSWAPME); return; }
  1043.  if(!FirstSeg) {Message(NOSEG); return;}
  1044.  if(SegSum >= SSpace) {Message(NOSPC); return;}
  1045.  if(PrevSelected->tc_State == 9) {Message(SWAPPED); return;}
  1046.  if(Confirm(9)) return; 
  1047.  if(!(file = fopen(SBuff,"w"))) {Message(NOFILE); return;}
  1048.  Message(WAIT);
  1049.  Forbid();
  1050.  PrevSelected->tc_State = 9; 
  1051.  Remove((struct Node *)PrevSelected);
  1052.  Insert(&(SysBase->IntrList),(struct Node *)PrevSelected,NULL);
  1053.  memcpy((char *)Sig,(char *)&(PrevSelected->tc_SigWait),12);
  1054.  memset((char *)&(PrevSelected->tc_SigWait),0,12);
  1055.  Permit();
  1056.  segment = FirstSeg;
  1057.  while(segment)
  1058.  {
  1059.   Lower =  (ULONG)segment + 4;
  1060.   SegSize = ((ULONG *)segment)[-1];
  1061.   segment = (APTR)(((ULONG *)segment)[0] * 4);
  1062.   if(SegSize < 200) continue;
  1063.   CurSeg = (APTR)(Lower - 8);
  1064.   actual = fwrite((char *)&CurSeg,4,1,file);
  1065.   if(actual != 1) {Message(WERROR); fclose(file); return;} 
  1066.   actual = fwrite((char *)&SegSize,4,1,file);
  1067.   if(actual != 1) {Message(WERROR); fclose(file); return;} 
  1068.   actual = fwrite((char *)CurSeg,1,SegSize,file);
  1069.   if(actual != SegSize) {Message(WERROR); fclose(file); return;} 
  1070.   FreeMem(CurSeg,SegSize);
  1071.   DisplayRam();
  1072.  }
  1073.  CurSeg = NULL;
  1074.  actual = fwrite((char *)&CurSeg,4,1,file);
  1075.  if(actual != 1) {Message(WERROR); fclose(file); return;} 
  1076.  actual = fwrite((char *)Sig,4,3,file);
  1077.  if(actual != 3) {Message(WERROR); fclose(file); return;}
  1078.  fclose(file); 
  1079.  RemoveGList(MainWin,&Bools[9],1);
  1080.  Bools[9].Flags |= GADGDISABLED;
  1081.  AddGList(MainWin,&Bools[9],9,1,NULL);
  1082.  RefreshGList(&Bools[9],MainWin,NULL,1);
  1083.  Message(DONE);
  1084. }
  1085.  
  1086.  
  1087. void SwapIn()
  1088. {
  1089.  int actual;
  1090.  ULONG Sig[3];
  1091.  
  1092.  if(!PrevSelected) {Message(NOTASK); return;}
  1093.  if(PrevSelected->tc_State != 9) {Message(NSWAPPED); return;}
  1094.  if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
  1095.  Message(WAIT);
  1096.  if(first) FreeList();
  1097.  SegSum = 0;
  1098.  NumSwap = 0;
  1099.  while(TRUE)
  1100.  {
  1101.   actual = fread((char *)&SegAddr,4,1,file);
  1102.   if(actual != 1) {FreeSwap(1); return;}
  1103.   if(SegAddr == NULL) break;
  1104.   actual = fread((char *)&SegSize,4,1,file);
  1105.   if(actual != 1) {FreeSwap(1); return;}  
  1106.   fclose(file); file = NULL;
  1107.   if(!AllocAbs(SegSize,SegAddr)) 
  1108.   {
  1109.    FreeSwap(0);
  1110.    Message(OCCUPIED1); Message(OCCUPIED2); 
  1111.    Message(FREED);
  1112.    return;
  1113.   }
  1114.   if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
  1115.   fseek(file,SegSum + (NumSwap + 1) * 8,0);
  1116.   actual = fread((char *)SegAddr,1,SegSize,file);
  1117.   if(actual != SegSize) {FreeSwap(1); return;} 
  1118.   NumSwap++;
  1119.   SegSum += SegSize;
  1120.  }   
  1121.  actual = fread((char *)Sig,4,3,file);
  1122.  if(actual != 3) {FreeSwap(1); return;}
  1123.  if(file) fclose(file);
  1124.  Forbid();
  1125.  PrevSelected->tc_State = 3;
  1126.  memcpy((char *)&(PrevSelected->tc_SigWait),(char *)Sig,12);
  1127.  Remove((struct Node *)PrevSelected);
  1128.  Insert(&(SysBase->TaskReady),(struct Node *)PrevSelected,NULL);
  1129.  Permit();
  1130.  Update();
  1131.  Message(DONE);
  1132. }
  1133.  
  1134.  
  1135. void FreeSwap(Arg)
  1136. int Arg;
  1137. {
  1138.  int count;
  1139.  
  1140.  if(file) fclose(file);
  1141.  if(Arg) Message(RERROR);
  1142.  if(!NumSwap) return;
  1143.  if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
  1144.  for(count = 0;count <NumSwap;count++)
  1145.  {
  1146.   fread((char *)&SegAddr,4,1,file);
  1147.   if(feof(file)) break;
  1148.   fread((char *)&SegSize,4,1,file);
  1149.   if(feof(file)) break;
  1150.   FreeMem(SegAddr,SegSize);
  1151.   DisplayRam();
  1152.   fseek(file,SegSize,1);
  1153.  }
  1154.  fclose(file);
  1155.  if(Arg) Message(FREED);
  1156. }    
  1157.  
  1158.  
  1159. void FindIntruder()
  1160. {
  1161.  struct TInfo *curtask,*temp,*cur;
  1162.  ULONG SegUp,Size,Up,skip,Lower;
  1163.  APTR Segment,Seg;
  1164.  int actual,NotFound = TRUE;
  1165.  
  1166.  if(!(file = fopen(SBuff,"r"))) {Message(NOFILE); return;}
  1167.  Message(WAIT);
  1168.  temp = first;
  1169.  if(GetList()) return;
  1170.  first = tinfo->prev;
  1171.  first->next = NULL;
  1172.  first = tinfo;
  1173.  while(TRUE)
  1174.  {
  1175.   curtask = temp;
  1176.   actual = fread((char *)&SegAddr,4,1,file);
  1177.   if(actual != 1) {Message(RERROR); fclose(file); return;}
  1178.   if(SegAddr == NULL)  break;
  1179.   actual = fread((char *)&SegSize,4,1,file);
  1180.   if(actual != 1) {Message(RERROR); fclose(file); return;} 
  1181.   SegUp = (ULONG)SegAddr + SegSize;
  1182.   while(FindTask((curtask->Addr)->tc_Node.ln_Name))
  1183.   {
  1184.    Segment = FindFirstSegment(curtask->Addr);
  1185.    while(Segment)
  1186.    {
  1187.     Lower = (ULONG)Segment + 4;
  1188.     Size = ((ULONG *)Segment)[-1];
  1189.     Segment = (APTR)(((ULONG *)Segment)[0] * 4);
  1190.     Seg = (APTR)(Lower - 8);
  1191.     Up = (ULONG)Seg + Size;
  1192.     skip = FALSE;
  1193.     if(((Seg > SegAddr) && ((ULONG)Seg < SegUp)) || 
  1194.                                        ((Up > (ULONG)SegAddr) && (Up < SegUp)))
  1195.     {
  1196.      for(cur = first;cur;cur = cur->next) 
  1197.       if(curtask->Addr == cur->Addr) skip = TRUE;
  1198.      if(!skip)
  1199.      { 
  1200.       sprintf(ErrorT[INTRUDER],"Intruder task address:%08lx ",curtask->Addr);
  1201.       tinfo->Addr = curtask->Addr;
  1202.       if(GetList()) { FreeList(); first = temp; fclose(file); return;}
  1203.       Message(INTRUDER);
  1204.       NotFound = FALSE;
  1205.      }
  1206.     }
  1207.    }
  1208.    if(!(curtask = curtask->next)) break; 
  1209.   }
  1210.   fseek(file,SegSize,1);
  1211.  } 
  1212.  FreeList();
  1213.  fclose(file);
  1214.  first = temp;
  1215.  if(NotFound) Message(INTNFOUND);
  1216.  else Message(DONE);
  1217. }
  1218.  
  1219.  
  1220. APTR FindFirstSegment(taskptr)
  1221. struct Task *taskptr;
  1222. {
  1223.  APTR segment = 0;
  1224.  struct Process *proc;
  1225.  struct CommandLineInterface *cli;
  1226.  
  1227.  if(taskptr->tc_State == 9) { return(NULL); }
  1228.  proc = (struct Process  *)taskptr;
  1229.  if(taskptr->tc_Node.ln_Type == 13)
  1230.  {   
  1231.   segment = (APTR)((proc->pr_SegList) << 2);
  1232.   segment = (APTR)(((ULONG *)segment)[3] << 2);
  1233.   if(!segment) 
  1234.   {
  1235.    cli = (struct CommandLineInterface *) (((ULONG)proc->pr_CLI) << 2); 
  1236.    segment = (APTR)((ULONG)cli->cli_Module << 2);
  1237.   }
  1238.  }
  1239.  return(segment);
  1240. }
  1241.  
  1242.  
  1243. void Seg()
  1244. {
  1245.  ULONG Lower,Upper,Size;
  1246.  APTR segment = 0;
  1247.  int count;
  1248.  struct Process *proc;
  1249.  struct TInfo *cur;
  1250.  char type[6];
  1251.  
  1252.  SegSum = 0; 
  1253.  FirstSeg = NULL;
  1254.  if(State == INFO)
  1255.  {
  1256.   State = TASKS;
  1257.   RemoveGList(MainWin,&Bools[3],13);
  1258.   Bools[12].GadgetText = &Texts[12];
  1259.   for (count = 3;count != 16;count++)  Bools[count].Flags &= ~GADGDISABLED;
  1260.   Bools[9].Flags = GADGDISABLED;  Bools[8].Flags = GADGDISABLED;
  1261.   Bools[15].Flags = GADGDISABLED;
  1262.   RemoveGList(MainWin,&Bools[3],13);
  1263.   if(PrevSelected->tc_State == 9 || PrevSelected->tc_State == 2)
  1264.   {
  1265.    for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  1266.    if(PrevSelected->tc_State == 9) 
  1267.     Bools[4].Flags = Bools[8].Flags = Bools[15].Flags &= ~GADGDISABLED;
  1268.    else 
  1269.    {
  1270.     Bools[4].Flags &= ~GADGDISABLED; 
  1271.     Bools[10].Flags = Bools[11].Flags = Bools[12].Flags &= ~GADGDISABLED;
  1272.    }
  1273.    Bools[3].Flags = Bools[13].Flags = Bools[14].Flags &= ~GADGDISABLED;
  1274.    Bools[6].Flags &= ~GADGDISABLED;
  1275.   }
  1276.   AddGList(MainWin,&Bools[3],3,13,NULL);
  1277.   WipeGadg();
  1278.   RefreshGList(&Bools[3],MainWin,NULL,13);
  1279.   RemoveGList(MainWin,Select,7);
  1280.   for (count = 0;count != 7;count++)  Select[count].Flags = GADGHCOMP;
  1281.   AddGList(MainWin,Select,-1,7,NULL);
  1282.   Texts[24].NextText = NULL;
  1283.   PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
  1284.   Texts[24].NextText = &Texts[23];
  1285.   UpdateTasks();
  1286.   return;
  1287.  }
  1288.  State = INFO;
  1289.  if(!PrevSelected) { Message(NOTASK); return; }
  1290.  if(PrevSelected->tc_State == 9) { Message(SWAPPED); return; }
  1291.  if(!FindTask(PrevSelected->tc_Node.ln_Name)) {Message(NOTFOUND); return;}
  1292.  TaskNum = 1;
  1293.  RemoveGList(MainWin,&Bools[3],13);
  1294.  Bools[12].GadgetText = &Texts[31];
  1295.  for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  1296.  Bools[12].Flags &= ~GADGDISABLED;
  1297.  if(PrevSelected->tc_State != 2) Bools[9].Flags = GADGHIMAGE;
  1298.  AddGList(MainWin,&Bools[3],3,13,NULL);
  1299.  WipeGadg();
  1300.  RefreshGList(&Bools[3],MainWin,NULL,13);
  1301.  RemoveGList(MainWin,Select,7);
  1302.  for (count = 0;count != 7;count++)  Select[count].Flags = GADGHNONE;
  1303.  AddGList(MainWin,Select,-1,7,NULL);
  1304.  PrintIText(RastPort,(struct IntuiText *)&Texts[33],10,0);
  1305.  if(first) FreeList();
  1306.  Disable();
  1307.  current = NULL;
  1308.  if(GetList()) {Enable(); return;}
  1309.  first = tinfo;
  1310.  proc = (struct Process  *)PrevSelected;
  1311.  if(PrevSelected->tc_Node.ln_Type == 13)
  1312.  {   
  1313.   if(PrevSelected->tc_State == 9) {Message(SWAPPED); Enable(); return;}
  1314.   if(!FindTask(PrevSelected->tc_Node.ln_Name))  
  1315.                                   {Message(NOTFOUND); Enable(); return;}
  1316.   segment = FindFirstSegment(PrevSelected);
  1317.   FirstSeg = segment;
  1318.   while(segment)
  1319.   {
  1320.    TaskNum++;
  1321.    Lower =  (ULONG)segment + 4;
  1322.    Size = ((ULONG *)segment)[-1];
  1323.    Upper = Lower + Size - 8;
  1324.    SegSum += Size;
  1325.    if(MEMF_CHIP & TypeOfMem(Lower)) strcpy(type,"CHIP");
  1326.    else strcpy(type,"FAST");
  1327.    sprintf(tinfo->data,"  %08lx           %08lx    %10lu   %s %-23s",
  1328.            Lower,Upper,Size,type," ");
  1329.    if(GetList()) {Enable(); return;}
  1330.    segment = (APTR)(((ULONG *)segment)[0] * 4);
  1331.   }
  1332.  } 
  1333.  Enable();
  1334.  if(SegSum == 0) Bools[9].Flags |= GADGDISABLED;
  1335.  RefreshGList(&Bools[9],MainWin,NULL,1);
  1336.  sprintf(tinfo->data,"Total Memory: %10lu                            %-21s",
  1337.          SegSum," ");
  1338.  for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++) 
  1339.  {
  1340.   ItemAddr[count] = cur;
  1341.   SelTexts[count].IText = cur->data;
  1342.  }
  1343.  if(count < 7) ClearSelect(count);
  1344.  ModifyP(0);
  1345.  RefreshGList(Select,MainWin,NULL,7); 
  1346. }  
  1347.  
  1348.      
  1349. void GetInfo()
  1350. {
  1351.  struct Process *proc = (struct Process *)PrevSelected;
  1352.  struct Window *PW;
  1353.  struct CommandLineInterface *cli;
  1354.  struct TInfo *cur;
  1355.  UBYTE  title[40];
  1356.  int    count;
  1357.  APTR   segment; 
  1358.  
  1359.  if(State == INFO)
  1360.  {
  1361.   State = TASKS;
  1362.   RemoveGList(MainWin,&Bools[3],13);
  1363.   Bools[4].GadgetText = &Texts[4];
  1364.   for (count = 3;count != 16;count++)  Bools[count].Flags &= ~GADGDISABLED;
  1365.   Bools[9].Flags = GADGDISABLED; 
  1366.   if(PrevSelected->tc_State == 9 || PrevSelected->tc_State == 2)
  1367.   {
  1368.    for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  1369.    if(PrevSelected->tc_State == 9) 
  1370.     Bools[4].Flags = Bools[8].Flags = Bools[15].Flags &= ~GADGDISABLED;
  1371.    else 
  1372.    {
  1373.     Bools[4].Flags &= ~GADGDISABLED; 
  1374.     Bools[10].Flags = Bools[11].Flags = Bools[12].Flags &= ~GADGDISABLED;
  1375.    }
  1376.    Bools[3].Flags = Bools[13].Flags = Bools[14].Flags &= ~GADGDISABLED;
  1377.    Bools[6].Flags &= ~GADGDISABLED;
  1378.   }
  1379.   AddGList(MainWin,&Bools[3],3,13,NULL);
  1380.   WipeGadg();
  1381.   RefreshGList(&Bools[3],MainWin,NULL,13);
  1382.   RemoveGList(MainWin,Select,7);
  1383.   for (count = 0;count != 7;count++)  Select[count].Flags = GADGHCOMP;
  1384.   AddGList(MainWin,Select,-1,7,NULL);  
  1385.   Texts[24].NextText = NULL;
  1386.   PrintIText(RastPort,(struct IntuiText *)&Texts[24],10,0);
  1387.   Texts[24].NextText = &Texts[23];
  1388.   UpdateTasks();
  1389.   return;
  1390.  }
  1391.  State = INFO;
  1392.  if(!PrevSelected) { Message(NOTASK); return; }
  1393.  RemoveGList(MainWin,&Bools[3],13);
  1394.  Bools[4].GadgetText = &Texts[31];
  1395.  for (count = 3;count != 16;count++)  Bools[count].Flags |= GADGDISABLED;
  1396.  Bools[4].Flags &= ~GADGDISABLED;
  1397.  AddGList(MainWin,&Bools[3],3,13,NULL);
  1398.  RefreshGList(&Bools[3],MainWin,NULL,13);
  1399.  RemoveGList(MainWin,Select,7);
  1400.  for (count = 0;count != 7;count++)  Select[count].Flags = GADGHNONE;
  1401.  AddGList(MainWin,Select,-1,7,NULL);
  1402.  PrintIText(RastPort,(struct IntuiText *)&Texts[32],10,0);
  1403.  Disable();
  1404.  current = NULL;
  1405.  if(first) FreeList();
  1406.  if(GetList()) {Enable(); return;}
  1407.  sprintf(tinfo->data,"Task Information:                           %-30.30s",
  1408.          " ");
  1409.  first = tinfo;
  1410.  if(GetList()) {Enable(); return;}
  1411.  sprintf(tinfo->data,"IDNestCnt = %08lx           TDNestCnt = %08lx     %-17s",
  1412.          proc->pr_Task.tc_IDNestCnt,proc->pr_Task.tc_TDNestCnt," ");
  1413.  if(GetList()) {Enable(); return;}
  1414.  sprintf(tinfo->data,"SigAlloc = %08lx            SigWait = %08lx       %-17s",
  1415.          proc->pr_Task.tc_SigAlloc,proc->pr_Task.tc_SigWait," ");
  1416.  if(GetList()) {Enable(); return;}
  1417.  sprintf(tinfo->data,"SigRecvd = %08lx            SigExcept = %08lx     %-17s",
  1418.          proc->pr_Task.tc_SigRecvd,proc->pr_Task.tc_SigExcept," ");
  1419.  if(GetList()) {Enable(); return;}
  1420.  sprintf(tinfo->data,"TrapAlloc = %08lx           TrapAble = %08lx      %-17s",
  1421.          proc->pr_Task.tc_TrapAlloc,proc->pr_Task.tc_TrapAble," ");
  1422.  if(GetList()) {Enable(); return;}
  1423.  sprintf(tinfo->data,"ExceptData = %08lx          ExceptCode = %08lx    %-17s",
  1424.          proc->pr_Task.tc_ExceptData,proc->pr_Task.tc_ExceptCode," ");
  1425.  if(GetList()) {Enable(); return;}
  1426.  sprintf(tinfo->data,"SPReg = %08lx                                  %-23s",
  1427.          proc->pr_Task.tc_SPReg," ");
  1428.  if(GetList()) {Enable(); return;}
  1429.  sprintf(tinfo->data,"SPLower = %08lx             SPUpper = %08lx       %-17s",
  1430.          proc->pr_Task.tc_SPLower,proc->pr_Task.tc_SPUpper," ");
  1431.  if(GetList()) {Enable(); return;}
  1432.  sprintf(tinfo->data,"Switch() : %08lx            Launch() : %08lx      %-17s",
  1433.          proc->pr_Task.tc_Switch,proc->pr_Task.tc_Launch," ");
  1434.  if(GetList()) {Enable(); return;}
  1435.  sprintf(tinfo->data,"UserData = %08lx                               %-20s",
  1436.          proc->pr_Task.tc_UserData);
  1437.  TaskNum = 10;
  1438.  if(proc->pr_Task.tc_Node.ln_Type == 13)
  1439.  {
  1440.   PW = (struct Window *)proc->pr_WindowPtr; 
  1441.   if(PW != (struct Window *)-1L && PW) strncpy(title,PW->Title,38);
  1442.   else strcpy(title,"");
  1443.   if(GetList()) {Enable(); return;}
  1444.   sprintf(tinfo->data,"Process Information:                          %-20s",
  1445.            " "); 
  1446.   if(GetList()) {Enable(); return;}
  1447.   sprintf(tinfo->data,"WindowPtr = %08lx          Title : %-22.22s",PW,title);
  1448.   if(GetList()) {Enable(); return;}
  1449.   sprintf(tinfo->data,"CurrentDir =  %08lx                           %-20s",
  1450.           proc->pr_CurrentDir << 2," ");
  1451.   if(GetList()) {Enable(); return;}
  1452.   sprintf(tinfo->data,"StackBase = %08lx          StackSize = %08lx     %-17s",
  1453.           proc->pr_StackBase << 2,proc->pr_StackSize," ");
  1454.   if(GetList()) {Enable(); return;}
  1455.   sprintf(tinfo->data,"CIS = %08lx                COS = %08lx           %-17s",
  1456.           proc->pr_CIS << 2,proc->pr_COS << 2," ");
  1457.   if(GetList()) {Enable(); return;}
  1458.   sprintf(tinfo->data,"ConsoleTask = %08lx        FileSystemTask = %08lx%-17s",
  1459.           proc->pr_ConsoleTask,proc->pr_FileSystemTask," ");
  1460.   segment = (APTR) (((ULONG)proc->pr_SegList) << 2);
  1461.   segment = (APTR) (((ULONG *)segment)[3] << 2);
  1462.   if(GetList()) {Enable(); return;}
  1463.   sprintf(tinfo->data,"SegList = %08lx            SegPointer = %08lx    %-17s",
  1464.           proc->pr_SegList << 2,segment," ");
  1465.   if(GetList()) {Enable(); return;}
  1466.   sprintf(tinfo->data,"PktWait = %08lx            CLI = %08lx           %-17s",
  1467.           proc->pr_PktWait,proc->pr_CLI," ");
  1468.   TaskNum += 8;
  1469.  }
  1470.  if(proc->pr_CLI)
  1471.  { 
  1472.   cli = (struct CommandLineInterface *)((ULONG)proc->pr_CLI << 2);
  1473.   if(GetList()) {Enable(); return;}
  1474.   sprintf(tinfo->data,"CommandLineInterface Information:             %-20s",
  1475.           " ");
  1476.   if(GetList()) {Enable(); return;}
  1477.   sprintf(tinfo->data,"CommandDir = %08lx                            %-20s",
  1478.           cli->cli_CommandDir << 2," ");
  1479.   if(GetList()) {Enable(); return;}
  1480.   sprintf(tinfo->data,"StdInput = %08lx           StdOutput = %08lx     %-17s",
  1481.           cli->cli_StandardInput << 2 ,cli->cli_StandardOutput << 2," ");
  1482.   if(GetList()) {Enable(); return;}
  1483.   sprintf(tinfo->data,"CurrentInput = %08lx       CurrentOutput = %08lx %-17s",
  1484.           cli->cli_CurrentInput << 2,cli->cli_CurrentOutput << 2," ");
  1485.   if(GetList()) {Enable(); return;}
  1486.   sprintf(tinfo->data,"Module = %08lx                                %-20s",
  1487.           cli->cli_Module << 2," ");
  1488.   TaskNum += 5;
  1489.  }
  1490.  Enable();
  1491.  for(cur = first,count = 0;count != 7;cur = cur->next,count++) 
  1492.  {
  1493.   ItemAddr[count] = cur;
  1494.   SelTexts[count].IText = cur->data;
  1495.  }
  1496.  RefreshGList(Select,MainWin,NULL,7); 
  1497.  ModifyP(0);
  1498. }  
  1499.  
  1500.  
  1501. void Kill()
  1502. {
  1503.  struct Window *CurWin,*CurWin2;
  1504.  struct Screen *CurScr;
  1505.  
  1506.  if(State == WINSCR)
  1507.  {
  1508.   if(!GraphPtr) { Message(NOGRAPH); return; }
  1509.   if(Confirm(7)) return;
  1510.   Disable();
  1511.   if(!strcmp(GraphPtr->tempname,"window"))
  1512.   {
  1513.    CurWin = (struct Window *)GraphPtr->Addr;
  1514.    if(CurWin->MenuStrip) ClearMenuStrip(GraphPtr->Addr);
  1515.    CloseWindow(GraphPtr->Addr);
  1516.   }
  1517.   else
  1518.   {
  1519.    CurScr = (struct Screen *)GraphPtr->Addr;
  1520.    CurWin = CurScr->FirstWindow;
  1521.    while(CurWin)
  1522.    {
  1523.     CurWin2 = CurWin->NextWindow;
  1524.     if(CurWin->MenuStrip) ClearMenuStrip(CurWin);
  1525.     CloseWindow(CurWin);
  1526.     CurWin = CurWin2;
  1527.    }
  1528.    CloseScreen(CurScr);
  1529.   }
  1530.   Enable();
  1531.   Message(DONE);
  1532.   DisplayRam();
  1533.   GraphPtr = NULL;
  1534.   State = TASKS;
  1535.   WinScr();
  1536.   return;
  1537.  } 
  1538.  if(!PrevSelected) { Message(NOTASK); return; }
  1539.  if(FindTask(PrevSelected->tc_Node.ln_Name))
  1540.  {
  1541.   if(PrevSelected->tc_State == 2) { Message(NOSUICIDE); return; }
  1542.   if(PrevSelected->tc_State == 9) { Message(NOKILL); return; }
  1543.   if(Confirm(7)) return;
  1544.   Disable();
  1545.   MP = (struct MsgPort *)SysBase->PortList.lh_Head;
  1546.   while(MP->mp_Node.ln_Succ)
  1547.   {
  1548.    if((MP->mp_SigTask == PrevSelected) && strcmp(MP->mp_Node.ln_Name,"IDCMP")) 
  1549.    {
  1550.     PredMP = (struct MsgPort *)MP->mp_Node.ln_Pred;
  1551.     DeletePort(MP);
  1552.     if(PredMP == (struct MsgPort *)&(SysBase->PortList)) 
  1553.              MP = (struct MsgPort *)SysBase->PortList.lh_Head;
  1554.     else MP = (struct MsgPort *)PredMP->mp_Node.ln_Succ;
  1555.    }
  1556.    else MP = (struct MsgPort *)MP->mp_Node.ln_Succ;
  1557.   }
  1558.   RemTask(PrevSelected);
  1559.   Enable();
  1560.   Update(); 
  1561.   Message(DONE);
  1562.  }
  1563.  else Message(NOTFOUND);
  1564. }
  1565.  
  1566.  
  1567. void Pri()
  1568. {
  1569.  int NewPri;
  1570.  
  1571.  if(State == MEMORY) { Message(NOTIMP); return; }
  1572.  if(!PrevSelected) { Message(NOTASK); return;}
  1573.  strcpy(Temp,SBuff);
  1574.  sprintf(SBuff,"%d",PrevSelected->tc_Node.ln_Pri);
  1575.  RefreshGList(&Bools[17],MainWin,NULL,1);
  1576.  PrintIText(RastPort,(struct IntuiText *) &Texts[29],10,0);
  1577.  ActivateGadget(&Bools[17],MainWin,NULL);
  1578.  Message(NEWPRI);
  1579.  do
  1580.  {
  1581.   WaitPort(MainWin->UserPort);
  1582.   message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
  1583.   class = message->Class;
  1584.   GadgetPtr = (struct Gadget *)message->IAddress;
  1585.   GadgetNum = GadgetPtr->GadgetID;
  1586.   ReplyMsg((struct Message *) message);
  1587.   switch(GadgetNum)
  1588.   {
  1589.    case  0: MoveDown(1);
  1590.             break;
  1591.    case  1: MoveUp(1);
  1592.             break;   
  1593.    case  2: PropMoved();
  1594.             break; 
  1595.   }
  1596.  } while(GadgetNum != 17);
  1597.  sscanf(SBuff,"%d",&NewPri);
  1598.  if((NewPri > 127) || (NewPri < -128))
  1599.  {
  1600.   Message(OUTRANGE); 
  1601.   strcpy(SBuff,Temp);
  1602.   RefreshGList(&Bools[17],MainWin,NULL,1);
  1603.   Texts[23].NextText = NULL;
  1604.   PrintIText(RastPort,(struct IntuiText *) &Texts[23],10,0);
  1605.   Texts[23].NextText = &Texts[22];
  1606.   DisplaySwap();
  1607.   return;
  1608.  }
  1609.  if(FindTask(PrevSelected->tc_Node.ln_Name))
  1610.  {
  1611.   SetTaskPri(PrevSelected,NewPri);
  1612.   UpdateTasks();
  1613.   Message(DONE);
  1614.  }
  1615.  else Message(NOTFOUND);
  1616.  Texts[23].NextText = NULL;
  1617.  PrintIText(RastPort,(struct IntuiText *) &Texts[23],10,0);
  1618.  Texts[23].NextText = &Texts[22];
  1619.  strcpy(SBuff,Temp);
  1620.  RefreshGList(&Bools[17],MainWin,NULL,1);
  1621.  DisplaySwap();
  1622. }
  1623.  
  1624.  
  1625. void SendSig()
  1626. {
  1627.  if(!PrevSelected) { Message(NOTASK); return; }
  1628.  if(PrevSelected->tc_State == 9) { Message(NOSIGNAL); return; }
  1629.  if(Confirm(10)) return;
  1630.  strcpy(Temp,SBuff);
  1631.  strcpy(SBuff,"");
  1632.  RefreshGList(&Bools[17],MainWin,NULL,1);
  1633.  ActivateGadget(&Bools[17],MainWin,NULL); 
  1634.  PrintIText(RastPort,(struct IntuiText *) &Texts[30],10,0);
  1635.  Message(SIGMASK);
  1636.  do
  1637.  {
  1638.   WaitPort(MainWin->UserPort);
  1639.   message = (struct IntuiMessage *)GetMsg(MainWin->UserPort);
  1640.   class = message->Class;
  1641.   GadgetPtr = (struct Gadget *)message->IAddress;
  1642.   GadgetNum = GadgetPtr->GadgetID;
  1643.   ReplyMsg((struct Message *) message);
  1644.   switch(GadgetNum)
  1645.   {
  1646.    case  0: MoveDown(1);
  1647.             break;
  1648.    case  1: MoveUp(1);
  1649.             break;   
  1650.    case  2: PropMoved();
  1651.             break; 
  1652.   }
  1653.  } while(GadgetNum != 17);
  1654.  sscanf(SBuff,"%08lx",&SigMask);
  1655.  if(FindTask(PrevSelected->tc_Node.ln_Name))
  1656.  {
  1657.   Signal(PrevSelected,SigMask);
  1658.   Delay(30);
  1659.   UpdateTasks();
  1660.   Message(DONE);
  1661.  }
  1662.  else Message(NOTFOUND);
  1663.  Texts[23].NextText = NULL;
  1664.  PrintIText(RastPort,(struct IntuiText *) &Texts[23],10,0);
  1665.  Texts[23].NextText = &Texts[22];
  1666.  strcpy(SBuff,Temp);
  1667.  RefreshGList(&Bools[17],MainWin,NULL,1);
  1668.  DisplaySwap();
  1669. }
  1670.  
  1671.  
  1672. void Break()
  1673. {
  1674.  if(!PrevSelected) { Message(NOTASK); return; }
  1675.  if(PrevSelected->tc_State == 9) { Message(NOBREAK); return; }
  1676.  if(Confirm(11)) return;
  1677.  if(FindTask(PrevSelected->tc_Node.ln_Name))
  1678.  {
  1679.   SMask = 0xf000L;
  1680.   SMask = SMask & PrevSelected->tc_SigAlloc;
  1681.   Signal(PrevSelected,SMask);
  1682.   Delay(30);
  1683.   UpdateTasks();
  1684.   Message(DONE);
  1685.  }
  1686.  else Message(NOTFOUND);
  1687. }
  1688.  
  1689.  
  1690. void DisplaySwap()
  1691.  struct InfoData *IF;
  1692.  struct FileLock *lock;
  1693.  char Path[100],*Pos;
  1694.  
  1695.  strcpy(SwapS,"N/A       ");
  1696.  IF = (struct InfoData *)
  1697.                         AllocMem(sizeof(struct InfoData),MEMF_CHIP|MEMF_CLEAR);
  1698.  if(!IF) 
  1699.  {
  1700.   Message(NOMEM);
  1701.   PrintIText(RastPort,(struct IntuiText *) &Texts[27],10,0);
  1702.   return;
  1703.  } 
  1704.  strcpy(Path,SBuff);
  1705.  Pos = strchr(Path,':');
  1706.  if(Pos) *(Pos + 1) = NULL; 
  1707.  lock = (struct FileLock *)Lock(Path,ACCESS_READ);
  1708.  if(lock)
  1709.  { 
  1710.   if(Info(lock,IF))
  1711.   {
  1712.    if(IF->id_DiskType == ID_DOS_DISK)
  1713.    {
  1714.     SSpace = (IF->id_NumBlocks - IF->id_NumBlocksUsed) * IF->id_BytesPerBlock;
  1715.     sprintf(SwapS,"%-10lu",SSpace);
  1716.    }
  1717.   }
  1718.   UnLock(lock);
  1719.  }  
  1720.  FreeMem(IF,sizeof(struct InfoData));
  1721.  PrintIText(RastPort,(struct IntuiText *) &Texts[27],10,0);
  1722.  
  1723.  
  1724. void Freeze()
  1725. {
  1726.  if(!PrevSelected) { Message(NOTASK); return; }
  1727.  if(PrevSelected->tc_State == 9) { Message(NOFREEZE); return; }
  1728.  if(PrevSelected->tc_State != 8)
  1729.  {
  1730.   if(FindTask(PrevSelected->tc_Node.ln_Name))
  1731.   {
  1732.    Disable();
  1733.    if(PrevSelected->tc_State == 2) { Enable(); Message(NOTME); return;}
  1734.    Remove((struct Node *)PrevSelected);
  1735.    Insert(&(SysBase->IntrList),(struct Node *)PrevSelected,NULL);
  1736.    PrevSelected->tc_State = 8;
  1737.    MP = (struct MsgPort *)SysBase->PortList.lh_Head;
  1738.    while(MP->mp_Node.ln_Succ)
  1739.    {
  1740.     if(MP->mp_SigTask == PrevSelected) MP->mp_Flags = PA_IGNORE;
  1741.     MP = (struct MsgPort *)MP->mp_Node.ln_Succ;
  1742.    }
  1743.   }
  1744.   else { Message(NOTFOUND); return; }
  1745.  }
  1746.  else
  1747.  {
  1748.   Disable();
  1749.   Remove((struct Node *)PrevSelected);
  1750.   Insert(&(SysBase->TaskReady),(struct Node *)PrevSelected,NULL);
  1751.   PrevSelected->tc_State = 3;
  1752.   MP = (struct MsgPort *)SysBase->PortList.lh_Head;
  1753.   while(MP->mp_Node.ln_Succ)
  1754.   {
  1755.    if(MP->mp_SigTask == PrevSelected) MP->mp_Flags = PA_SIGNAL;
  1756.    MP = (struct MsgPort *)MP->mp_Node.ln_Succ;
  1757.   }
  1758.  }
  1759.  Enable();
  1760.  if(PrevSelected->tc_State == 8) Bools[5].GadgetText = &Texts[42];
  1761.  else Bools[5].GadgetText = &Texts[5];
  1762.  RefreshGList(&Bools[5],MainWin,NULL,1 );
  1763.  UpdateTasks();
  1764.  Message(DONE);
  1765.  return;
  1766. }
  1767.  
  1768.  
  1769. void ClearSelect(count)
  1770. int count;
  1771. {
  1772.  char *SPC = 
  1773.   "                                                                         ";
  1774.   for(;count < 7;count++) SelTexts[count].IText = SPC;
  1775. }
  1776.  
  1777.  
  1778. void DisplayRam()
  1779. {
  1780.  ChipRam = AvailMem(MEMF_CHIP);
  1781.  FastRam = AvailMem(MEMF_FAST);
  1782.  sprintf(CRam,"%-10lu",ChipRam);
  1783.  sprintf(FRam,"%-10lu",FastRam);
  1784.  PrintIText(RastPort,(struct IntuiText *) &Texts[26],12,0);
  1785. }
  1786.  
  1787.  
  1788. void Message(ErrorNum)
  1789. int ErrorNum;
  1790.  int count;
  1791.  
  1792.  if(Row < 4)  
  1793.  {
  1794.   strcpy(ETextAddr[Row],ErrorT[ErrorNum]);
  1795.   PrintIText(RastPort,(struct IntuiText *) &ErrIntuiText[Row],10,0);
  1796.   Row += 1;
  1797.   return;
  1798.  }
  1799.  for(count = 0;count < 3;count++)
  1800.  {
  1801.   strcpy(ErrIntuiText[count].IText,ErrIntuiText[count + 1].IText);
  1802.   PrintIText(RastPort,(struct IntuiText *) &ErrIntuiText[count],10,0);
  1803.  }
  1804.  strcpy(ErrIntuiText[3].IText,ErrorT[ErrorNum]);
  1805.  PrintIText(RastPort,(struct IntuiText *) &ErrIntuiText[3],10,0); 
  1806. }
  1807.  
  1808.  
  1809. void UpdateTasks()
  1810. {
  1811.  int count; 
  1812.  struct TInfo *cur;
  1813.  
  1814.  if(first) FreeList();
  1815.  current = NULL;
  1816.  TaskNum = 1;
  1817.  SysBase->IntrList.lh_Type = NT_TASK;
  1818.  Disable();
  1819.  task = (struct Task *)SysBase->ThisTask;
  1820.  if(GetTaskInfo(task)) { Enable(); return; }
  1821.  first = tinfo;
  1822.  for(task = (struct Task *)SysBase->TaskReady.lh_Head;
  1823.             task->tc_Node.ln_Succ;task = (struct Task *)task->tc_Node.ln_Succ)
  1824.  {
  1825.   TaskNum++;
  1826.   if(GetTaskInfo(task)) { Enable(); return; }
  1827.  }
  1828.  for(task = (struct Task *)SysBase->TaskWait.lh_Head;
  1829.             task->tc_Node.ln_Succ;task = (struct Task *)task->tc_Node.ln_Succ)
  1830.  {
  1831.   TaskNum++;
  1832.   if(GetTaskInfo(task)) { Enable(); return; }
  1833.  }
  1834.  for(task = (struct Task *)SysBase->IntrList.lh_Head;
  1835.             task->tc_Node.ln_Succ;task = (struct Task *)task->tc_Node.ln_Succ)
  1836.  {
  1837.   TaskNum++;
  1838.   if(GetTaskInfo(task)) { Enable(); return; }
  1839.  }
  1840.  Enable();
  1841.  for(cur = first,count = 0;count != min(7,TaskNum);cur = cur->next,count++) 
  1842.  {
  1843.   ItemAddr[count] = cur;
  1844.   SelTexts[count].IText = cur->data;
  1845.  }
  1846.  if (count < 7) ClearSelect(count);
  1847.  RefreshGList(Select,MainWin,NULL,7); 
  1848.  ModifyP(0);
  1849. }  
  1850.  
  1851. void WipeGadg()
  1852. {
  1853.  int count;
  1854.  
  1855. for (count = 0;count != 3;count++)
  1856.    PrintIText(RastPort,(struct IntuiText *)&Texts[34],33,97 + 8 * count);
  1857.   PrintIText(RastPort,(struct IntuiText *)&Texts[34],33,115);
  1858. }
  1859.  
  1860. int GetTaskInfo(t)
  1861. struct Task *t;
  1862. {
  1863.  if(GetList()) return(FAILER); 
  1864.  GetTaskName(t);
  1865.  tinfo->Addr = t;
  1866.  sprintf(tinfo->data,"%-21.21s %4d  %-7s %7u  %-9s %08lx  %08lx ",
  1867.   tinfo->name,t->tc_Node.ln_Pri,state[(int)t->tc_State],
  1868.   (ULONG)t->tc_SPUpper - 2 -(ULONG)t->tc_SPLower,
  1869.   type[(int)t->tc_Node.ln_Type],t->tc_SigWait,t);
  1870.  return(SUCCESS);
  1871. }
  1872.  
  1873.  
  1874. int GetList()
  1875. {
  1876.  tinfo = (struct TInfo *)AllocMem(sizeof(struct TInfo),MEMF_PUBLIC|MEMF_CLEAR);
  1877.  if(!tinfo) { Message(NOMEM); return(FAILER); } 
  1878.  if(current)
  1879.  {
  1880.   tinfo->prev = current;
  1881.   current->next = tinfo;
  1882.   tinfo->next = NULL;
  1883.  }
  1884.  current = tinfo;
  1885.  return(SUCCESS);
  1886. }
  1887.  
  1888.  
  1889. void GetTaskName(t)
  1890. struct Task *t;
  1891. {
  1892.  struct Process *proc;
  1893.  struct CommandLineInterface *cli;
  1894.  UBYTE *str,*cliname;
  1895.  int num;
  1896.  
  1897.  if(t->tc_Node.ln_Type == 13)
  1898.  {
  1899.   proc = (struct Process *)t;
  1900.   if(proc->pr_TaskNum == 0)  tinfo->name = proc->pr_Task.tc_Node.ln_Name;
  1901.   else
  1902.   {
  1903.    num = proc->pr_TaskNum;
  1904.    cli = (struct CommandLineInterface *)((long)(proc->pr_CLI) << 2);
  1905.    str = (UBYTE *)((long)(cli->cli_CommandName) << 2);
  1906.    cliname = (UBYTE *)BCPLtoC(str);
  1907.    if(*(cliname) == 0) cliname = "Unloaded CLI";
  1908.    sprintf(tinfo->tempname,"[CLI %d] %-25.25s",num,cliname);
  1909.    tinfo->name = tinfo->tempname;
  1910.   }
  1911.  }
  1912.  else  tinfo->name = t->tc_Node.ln_Name;
  1913. }  
  1914.  
  1915.  
  1916. UBYTE *BCPLtoC(bstring)
  1917. UBYTE *bstring;
  1918. {
  1919.  UBYTE strbuffer[256];
  1920.  int len = *bstring++;
  1921.  strncpy(strbuffer,bstring,len);
  1922.  *(strbuffer + len) = NULL;
  1923.  return(strbuffer);
  1924. }
  1925.  
  1926.  
  1927. void FreeList()
  1928. {
  1929.  struct TInfo *temp,*next;
  1930.  
  1931.  temp = first;
  1932.  while(temp != NULL)
  1933.  {
  1934.   next = temp->next;
  1935.   FreeMem(temp,sizeof(struct TInfo));
  1936.   temp = next;
  1937.  }
  1938.  first = NULL;
  1939.  
  1940. void CloseAll(RetCode)
  1941. int RetCode;
  1942. {
  1943.  if(UpData) FreeMem(UpData,sizeof(Up));
  1944.  if(DownData) FreeMem(DownData,sizeof(Down));
  1945.  if(MainWin) CloseWindow(MainWin);
  1946.  if(MainScr) CloseScreen(MainScr);
  1947.  if(DOSBase) CloseLibrary(DOSBase);
  1948.  if(GfxBase) CloseLibrary(GfxBase);
  1949.  if(IntuitionBase) CloseLibrary(IntuitionBase);
  1950.  exit(RetCode);
  1951. }
  1952.